<template>
  <div>
    <ul>
      <span v-for="(item, index) in arr" :key="index">
        <label :for="item"
          ><input
            type="checkbox"
            name=""
            :id="item"
            v-model="arr1"
            :value="item"
          />{{ item }}</label
        >
      </span>
    </ul>
    <h2>你选中的元素，累加的值和为: {{ sum }}</h2>
  </div>
</template>

<script>
export default {
  // name: "",
  components: {},
  props: {},
  data() {
    return {
      arr: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      arr1: [],
    };
  },
  computed: {
    sum() {
      return this.arr1.reduce((pre, item) => pre + item, 0);
    },
  },
  watch: {},
  created() {},
  methods: {},
};
</script>

<style lang="less" scoped></style>
